<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@page import="java.util.*" %>
    <%@page import="com.java.fileman.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="style.css" type="text/css"></link>
<title>Insert title here</title>
</head>
<body>
<div id="header">
<h1>Document management system</h1>
<% 
AuthToken authToken = (AuthToken) request.getAttribute("userInfo");
%>
<p>Name : <%=authToken.getName() %></p>
<p>Role : <%=authToken.getGroup() %></p>
<p><a href="AuthServlet?action=LOGOFF">LOG OFF</a></p>
</div>

<div id="main">
<h1>File Table</h1>
<% 
List<FileObject> files = (ArrayList) request.getAttribute("files"); 
%>
<% 
int count = 0;
%>
<table border="0" cellspacing="0" width="100%">
<tr><th>#</th> <th>Type</th><th>Name</th><th>Size</th>  <th>Permission</th></tr>
<tr><td>0</td><td><a href="?f=..">TOP</a></td><td>..</td> <td></td> <td></td></tr>
<% 
for(FileObject fileObject : files){

	count++;
	String color = "#FFF";
	if(count%2==0){
		color = "#F5F5F5";
	}
	%>

<tr style="background:<%=color%>">
<td width="50px"><%=count %></td>
<td><a href="?f=<%=fileObject.getId()%>"><img src="<%=fileObject.getType() > 0 ? "images/file.png" : "images/folder.png" %>"/></a></td>
<td><%=fileObject.getName() %></td>
<td width="100px"><%=fileObject.getSize() > 0 ? fileObject.getSize()/1024+" KB" : " - "%></td>
<td width="60px"><%=fileObject.getPermission() %></td>
</tr>
<% }%>
</table>
</div>
</body>
</html>